package com.team.mp.api.controller;

import com.team.mp.api.bo.ServicePackBo;
import com.team.mp.api.service.intf.ServicePackService;
import com.team.mp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author fan_lee
 * @date 2023/3/28 21:24
 */
@RestController
@RequestMapping("/api/sp/")
@Api(tags = "服务包相关接口")
public class ServicePackController {
    @Resource
    private ServicePackService packService;

    @GetMapping("list")
    @ApiOperation(value = "获取服务包列表")
    public R servicePacks(){
        return packService.servicePackList();
    }

    @GetMapping("detail")
    @ApiOperation(value = "获取服务包详情")
    public R servicePackDetail(Integer id){
        return packService.servicePackDetail(id);
    }

    @PostMapping("audit")
    @ApiOperation(value = "修改服务包状态")
    public R updateAudit(@RequestParam("status") Integer status,@RequestParam("id") Integer id){
        return packService.updateAuditStatus(status, id);
    }

    @GetMapping("selectedItems")
    @ApiOperation(value = "已选择的项目")
    public R selectItems(Integer id){
        return packService.selectedItems(id);
    }

    @PostMapping("addItems")
    @ApiOperation(value = "服务包新增项目")
    public R addItems(@RequestParam("itemIds") List<Integer> itemIds, @RequestParam("id") Integer id){
        return packService.addItems(itemIds, id);
    }

    @PostMapping("addPack")
    @ApiOperation(value = "服务包新增")
    public R addPack(@RequestBody ServicePackBo bo){
        return packService.add(bo);
    }

    @GetMapping("delete")
    @ApiOperation(value = "服务包删除")
    public R delete(Integer id){
        return packService.delete(id);
    }

}
